package com.linhngua.code.data.people;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;


import com.linhngua.code.data.LimitedSizeSet;
import com.linhngua.code.data.shop.Shop;

@Entity
public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected int id;

	private String name;

	private String password;

	private String imageUrl;

	private Date joinDate;

	protected Collection<Shop> lastViewShops;
	
	protected Collection<Shop> favoriteShops;

	public User() {
		lastViewShops = new LimitedSizeSet<Shop>(10);
		favoriteShops=new HashSet<Shop>();
	}

	public User(String name, String password, Date joinDate) {
		super();
		this.name = name;
		this.password = password;
		this.joinDate = joinDate;
		favoriteShops=new HashSet<Shop>();
		lastViewShops = new LimitedSizeSet<Shop>(10);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Date getJoinDate() {
		return joinDate;
	}

	public void setJoinDate(Date joinDate) {
		this.joinDate = joinDate;
	}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}
	
	@OneToMany(cascade=CascadeType.ALL)
	@JoinColumn(name="User_id")
	public Collection<Shop> getLastViewShops() {
		return lastViewShops;
	}
	
	
	public void setLastViewShops(Collection<Shop> lastViewShops) {
		this.lastViewShops = lastViewShops;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@OneToMany(cascade=CascadeType.ALL)
	@JoinColumn(name="User_id")
	public Collection<Shop> getFavoriteShops() {
		return favoriteShops;
	}

	public void setFavoriteShops(Collection<Shop> favoriteShops) {
		this.favoriteShops = favoriteShops;
	}
	
}
